package com.lupan.tomcatStudy.javaStudy.chapter16.callable;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * 说明：
 *
 * @author lupan
 * @version 2017/3/16 9:45
 */
public class CallTest {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CallThread callThread = new CallThread();
        FutureTask<Integer> futureTask = new FutureTask<Integer>(callThread);
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName() + "的循环变量i的值：" + i);
            if (i == 20) {
                new Thread(futureTask, "有返回值的线程").start();
            }

            if (i == 90) {
                System.out.println("子线程的返回值:" + futureTask.get());
            }
        }
    }
}
